<html>
    <head>
        <title></title>
        <link href="style3.css" rel="stylesheet" type="text/css" />
    </head>
    <?php
//checks on wether the conference id was sent or not 
    If (isset($_GET['conference_id'])) {
// establish a database connection
        $conn = @mysql_connect('localhost', 'root', '') or die(mysql_error());
        mysql_select_db("mydb") or die(mysql_error);
        // save the conference id in a variable 
        $conference_id = $_GET['conference_id'];
        $get_name = mysql_query("Select long_name From conference Where conference_id = '$conference_id'") or die(mysql_error());
        $Get_name = mysql_fetch_assoc($get_name);
        echo "<h1>{$Get_name['long_name']}</h1>";
        // execute the query that gets the first , last name of the member as well as his id 
        $select_members = mysql_query("SELECT DISTINCT first_name, last_name , m.member_id FROM member m  , member_privileges mp where m.member_id = mp.member_id AND  mp.conference_id= '$conference_id' ORDER BY first_name ASC ")
                or die(mysql_error());

        if (mysql_num_rows($select_members) > 0) {

            echo '<table width="100%">
        <tr>
        <td><b>Member</b></td>
        </tr>';
//display  each member's name in a hyperlink whenever the user clicks on this link he will be redirected to the profile page of this member 
            while ($row = mysql_fetch_assoc($select_members)) {
			
			if( $row['first_name'] != NULL )
			{

                echo"
	<tr>
	<td><a href='ProfilePage.php?member_id={$row['member_id']}'>{$row['first_name']} {$row['last_name']}</a></td>

	 </tr>";
	 }
	 else 
	 {
	  $select_members2 = mysql_query("SELECT email FROM member m WHERE m.member_id={$row['member_id']}")
                or die(mysql_error());
				
				$row2= mysql_fetch_assoc($select_members2);
				
				
	            echo"
	<tr>
	<td><a href='ProfilePage.php?member_id={$row['member_id']}'>{$row2['email']}</a></td>

	 </tr>";
	 
	 
            }



        }
		      echo '</table>';
        mysql_close($conn);	
		}else {
            echo "There are no members in this conference";
        }
    }
    ?> 